<template>
<div class="comment-box">
  <div class="content">
    <el-form  class="myForm"  v-model="myForm" label-width="100px" >
      <el-form-item label="评论内容">
       <el-input  type="textarea" v-model="myForm.content"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="submit">发表评论</el-button>
      </el-form-item>
    </el-form>
  </div>
</div>
</template>

<script>
import axios from "axios";
import bus from "@/assets/js/bus";
export default {
  name: "Comment",
  props:['id'],
  data(){
    return{
      myForm: {
        discussId:this.discussId,
        username: localStorage.getItem("username"),
        content:'',
        img: localStorage.getItem("img")
      }
    }
  },
  methods: {
    submit(){
      this.myForm.discussId = this.id
      axios.post('/FinancialRecommend/discuss/submitComment',this.myForm)
      .then(response => {
        debugger
        this.myForm.content = ''
        console.log(response)
        bus.$emit('refresh-comments');
        this.$message({
          message: '评论成功',
          type: 'success'
        })
      })
    }
  }
}
</script>

<style lang="less" scoped>
.comment-box{
  width: 100%;
  height: 100px;
  .content{
    //min-height: 400px;
    width: 100%;
    margin: 0 auto;
    padding: 30px;
    box-sizing: border-box;
    font-weight: lighter;
    box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s ease;
  }
}
.content:hover{
  box-shadow:  0 2px 20px 6px rgba(0, 0, 0, 0.12);
}
</style>
